﻿
Partial Class confirm
    Inherits System.Web.UI.Page



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim paramString As String = Request.RawUrl()
        If InStr(paramString, "id=", CompareMethod.Text) = 0 Then
            Response.Redirect("Home.aspx")
            Exit Sub
        Else

            uhOh.Visible = False
            'Dim myTime As DateTime = Now()
            'Dim newTime As DateTime = Now()

            Try



                'newTime = Now().AddSeconds(3)
                'Do Until myTime = newTime
                'myTime = Now()
                'Loop
                Dim myGuid As Guid = New Guid(Request.Params("id"))
                Dim user As MembershipUser = Membership.GetUser(myGuid)
                user.IsApproved = True
                Membership.UpdateUser(user)

                showNeg(True)

            Catch ex As Exception

                showNeg(False)
            End Try
        End If



    End Sub

    Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete


    End Sub

    Protected Sub validateMe_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles validateMe.Click


        Try
            Dim myGuid As Guid = New Guid(Request.Params("id"))
            Dim user As MembershipUser = Membership.GetUser(myGuid)
            user.IsApproved = True

            System.Threading.Thread.Sleep(5000)

            FormsAuthentication.RedirectFromLoginPage(user.UserName, False)
        Catch ex As Exception

            System.Threading.Thread.Sleep(5000)
            Response.Redirect("Home.aspx")
        End Try
        


    End Sub

    Sub showNeg(ByVal isValidated As Boolean)

        If isValidated = True Then
            
            headerLabel.Text = "Thank you. Your email address has been verified. You will now be redirected."
        Else
            uhOh.Visible = True
            headerLabel.Text = "Your account credentials could not be verified. You will now be redirected . . ."
        End If


    End Sub
End Class
